import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:tracker/common/enums/user_type_enum.dart';
import 'package:tracker/pages/home/home/model/home_device_info_resp.dart';
import 'package:tracker/pages/home/home/model/user_info_resp.dart';
import 'package:tracker/pages/msg/model/alarm_list_resp.dart';
import 'package:tracker/provider/notifier/device_info_notifier.dart';
import 'package:tracker/provider/notifier/user_info_notifier.dart';

import '../pages/home/location/model/monitor_data_resp.dart';

/// 记住密码
final rememberPasswordProvider = StateProvider((ref) => false);

// 更换图标
final updateIconProvider = StateProvider((ref) => 0);

// final mapShowProvider = StateProvider((ref) => 0);

final buttonShowProvider = StateProvider<ButtonShowState>((ref) => ButtonShowState());


// 消息
final alarmDataProvider = StateProvider((ref) => AlarmData());

// 设备
final monitorDataProvider = StateProvider((ref) => MonitorData());

/// 用户类型
final userTypeProvider = StateProvider<UserTypeEnum>((ref) {
  // 读取用户数据
  final userInfo = ref.watch(userInfoProvider);
  return userInfo.type != null ? UserTypeEnum.fromValue(userInfo.type!) : UserTypeEnum.none;
});

/// 用户数据
final userInfoProvider = StateNotifierProvider<UserInfoNotifier, UserInfoData>((ref) => UserInfoNotifier());

/// 设备数据
final deviceInfoProvider = StateNotifierProvider<DeviceInfoNotifier, DeviceInfoVO>((ref) {
  return DeviceInfoNotifier(ref);
});


/// 是否显示过充值弹窗提示
bool hasShowRechargeDialog = false;


class ButtonShowState {
  final int showanfangluyin;    // 开始录音按钮状态
  final int showzengzhifuwu;    // 增值服务按钮状态
  final int showshengyinbaojing; // 声音报警按钮状态

  ButtonShowState({
    this.showanfangluyin = 0,   // 默认值为0
     this.showzengzhifuwu = 0,
    this.showshengyinbaojing = 0,
  });

  // 复制方法，用于创建新状态
  ButtonShowState copyWith({
    int? showanfangluyin,
    int? showzengzhifuwu,
    int? showshengyinbaojing,
  }) {
    return ButtonShowState(
      showanfangluyin: showanfangluyin ?? this.showanfangluyin,
      showzengzhifuwu: showzengzhifuwu ?? this.showzengzhifuwu,
      showshengyinbaojing: showshengyinbaojing ?? this.showshengyinbaojing,
    );
  }
}